<?php

namespace App\Api\Eloquent;

class ProjectsUser extends Model
{
    protected $table='projects_user';

    public static function getProjects($user_id){
        $lists=ProjectsUser::where('user_id','=',$user_id)
            ->get();
        foreach($lists as $list){
            $projects_ids[]=$list->projects_id;
        }
        if($projects_ids){
            $projects_ids=array_unique($projects_ids);
            return Projects::whereIn('id',$projects_ids)
                ->get();
        }
        return null;
    }
}